import Vue from 'vue'
import VueRouter from 'vue-router'
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function (location) {
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/jdselectgoods',
    component: () =>
      import(
        /* webpackChunkName: "homepage" */ '@/views/jdselectgoods/index.vue'
      )
  },
  {
    path: '/about',
    name: 'About',
    component: () =>
      import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () =>
      import(/* webpackChunkName: "login" */ '@/views/login/login.vue'),
    meta: {
      title: '登录',
      showtab: false
    }
  },
  {
    path: '/forgetpass',
    name: 'Forgetpass',
    component: () =>
      import(
        /* webpackChunkName: "forgetpass" */ '@/views/login/forgetpass.vue'
      ),
    meta: {
      title: '忘记密码',
      showtab: false
    }
  },
  {
    path: '/help',
    name: 'help',
    component: () =>
      import(
        /* webpackChunkName: "help" */ '@/views/help/index.vue'
      ),
    meta: {
      title: '帮助中心',
      showtab: false
    }
  },
  {
    path: '/cooperation',
    name: 'cooperation',
    component: () =>
      import(
        /* webpackChunkName: "cooperation" */ '@/views/cooperation/index.vue'
      ),
    meta: {
      title: '商家合作',
      showtab: false
    }
  },
  {
    path: '/settled',
    name: 'settled',
    component: () =>
      import(
        /* webpackChunkName: "cooperation" */ '@/views/settled/index.vue'
      ),
    meta: {
      title: '招商入驻',
      showtab: false
    }
  },
  {
    path: '/jdselectgoods',
    name: 'jdselectgoods',
    redirect: '/jdselectgoods/realtimelist',
    component: () =>
      import(
        /* webpackChunkName: "homepage" */ '@/views/jdselectgoods/index.vue'
      ),
    meta: {
      title: '首页',
      showtab: false
    },
    children: [
      {
        path: 'homepage',
        name: 'homepage',
        component: () => import('@/views/jdselectgoods/homepage/index'),
        meta: {
          title: '首页'
        }
      },
      {
        path: 'goodsdetails',
        name: 'goodsdetails',
        component: () => import('@/views/jdselectgoods/goodsdetails/index'),
        meta: {
          title: '商品详情'
        }
      },
      {
        path: 'realtimelist',
        name: 'realtimelist',
        component: () => import('@/views/jdselectgoods/realtimelist/index'),
        meta: {
          title: '实时榜单'
        }
      },
      {
        path: 'allgoods',
        name: 'allgoods',
        component: () => import('@/views/jdselectgoods/allgoods/index'),
        meta: {
          title: '全部商品'
        }
      },
      {
        path: 'supercdr',
        name: 'supercdr',
        component: () => import('@/views/jdselectgoods/supercdr/index'),
        meta: {
          title: '超市素材库'
        }
      },
      {
        path: 'business',
        name: 'business',
        component: () => import('@/views/jdselectgoods/business/index'),
        meta: {
          title: '商家信息墙'
        }
      },
      {
        path: 'aisystem',
        name: 'aisystem',
        component: () => import('@/views/jdselectgoods/aisystem/index'),
        meta: {
          title: '招商系统'
        }
      },
      {
        path: 'widge',
        name: 'widge',
        redirect: '/jdselectgoods/widge/widgepic',
        component: () => import('@/views/jdselectgoods/widge/index'),
        meta: {
          title: '小工具'
        },
        children: [
          {
            path: 'widgepic',
            name: 'widgepic',
            component: () => import('@/views/jdselectgoods/widge/widgepic'),
            meta: {
              title: '营销图制作'
            }
          }
        ]
      },
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
